<?php if (!defined('THINK_PATH')) exit();?>      <p class="user_title" style="height: 40px;line-height: 40px;border-bottom: 1px solid #fff;">
        <span style="font-size: 20px; padding-left: 12px;"><?php echo ($data); ?></span>
      </p>
       <form class="form-horizontal" >
		   <div class="form-group">
		    <label for="msg" class="col-sm-2 control-label"></label>
		    <div class="col-sm-4">
		     <span id="msg" style="color:red;font-size:20px; display:none"></span>
		    </div>
		  </div>
		  <div class="form-group">
		    <label for="username" class="col-sm-2 control-label">新密码</label>
		    <div class="col-sm-4">
		      <input type="password" class="form-control" id="password"  >
		    </div>
		  </div>
		    <div class="form-group">
		    <label for="username" class="col-sm-2 control-label">密码确认</label>
		    <div class="col-sm-4">
		      <input type="password" class="form-control" id="repassword"  >
		    </div>
		  </div>
		    <div class="form-group">
		    <label for="username" class="col-sm-2 control-label">验证码</label>
		    <div class="col-sm-2">
		      <input type="text" class="form-control" id="code" >
		    </div>
		     <div class="col-sm-2">
		      <img id="getcode_math" src="<?php echo u('get_code');?>" title="看不清，点击换一张" style="cursor:pointer"  onerror="" alt="..." />
		    </div>
		  </div>
		    <div class="form-group">
		    <div class="col-sm-offset-2 col-sm-10">
		      <button type="submit" id="submit" class="btn btn-default">保存</button>
		    </div>
		  </div>
</form>
<script type="text/javascript">
   $(function(){
   //算术验证
      $("#getcode_math").click(function(){
         $(this).attr("src","<?php echo u('get_code');?>?" + Math.random());
      });

     $('#submit').bind('click',sub_message);
   });

   function sub_message(){
		  var code= $('#code').val();
          var password= $('#password').val();
          var repassword= $('#repassword').val();
          
          if(password ==""){
            $('#msg').html('密码不能为空!').show();
            return;
          }
          if(password.length < 4 || password.length > 16){
           $('#msg').html('密码不能小于4位大于16位!').show();
            return;
          }
         if(repassword == ""){
           $('#msg').html('密码确认不能为空!').show();
           return;
         }

         if(password!== repassword){
           $('#msg').html('两次输入的密码不一致!').show();
           return;
         }
  	      if(code ==""){
            $('#msg').html('验证码不能为空!').show();
            return;
          }
               $.ajax({
                 url: "<?php echo u('User/news_password');?>",
                 type: 'POST',
                 dataType: 'json',
                 data: {"code": code,
                        "password" : password,
                        "repassword" : repassword
                 },
                 complete: function(xhr, textStatus) {
                   //called when complete
                 },
                 success: function(data) {
                   if(data.status == 1){
                    $('#msg').html(data.msg).css('color','green').show();
                    setTimeout(function(){
                       $('#msg').html("").hide().css('color','red');
                    },1000);
	        		  var code= $('#code').val('');
			          var password= $('#password').val('');
			          var repassword= $('#repassword').val('');
                   }else{
                    $('#msg').html(data.msg).show();
                    setTimeout(function(){
                       $('#msg').html("").hide();
                    },1000);
                      var code= $('#code').val('');
			          var password= $('#password').val('');
			          var repassword= $('#repassword').val('');
                   }
                 },
                 error: function(xhr, textStatus, errorThrown) {
                   //called when there is an error
                 }
             });
 }
</script>